package ch.cern

/**
 * Created with IntelliJ IDEA.
 * User: ndecreve
 * Date: 04/05/12
 * Time: 13:46
 * To change this template use File | Settings | File Templates.
 */
class BootStrapUnit {

  static bootStrap() {
    def tags = [rest:new Tag(tag:"restaurant"), hol:new Tag(tag:"holiday"), work:new Tag(tag:"work"), drink:new Tag(tag:"drink")]
    def map = new Map(name:'Dubna', createdOn: new Date()-1500)
    def points = [new Point(title:'University', description:'University', latitude:56.747499, longitude:37.190094,
          createdOn: new Date()-1000, tags: [tags.work], map:map),
    new Point(title:'Pizza Place',description:'Pizza Place', latitude:56.745099, longitude:37.177877,
          createdOn: new Date()-500, tags: [tags.drink, tags.rest], map:map),
    new Point(title:'Dubna Pizza',description:'Dubna Pizza', latitude:56.742463, longitude:37.176955,
          createdOn: new Date(), tags: [tags.drink, tags.rest], map:map),
    new Point(title:'Geneva',description:'Cern', latitude:46.234196, longitude:6.056083,
          createdOn: new Date()-100, tags: [tags.work, tags.hol], map:map) ]

    //bug in 2.0.3, cannot do this
    //points.each{map.addToPoints(it)}

    tags.values().each{it.save(failOnError:true)}
    map.save(failOnError:true)
    points.each{it.save(failOnError:true)}
  }
}